import fetch from 'common/src/utils/fetch';

/**
 * 分页查询教学任务信息
 */
export function getPageList(data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/page2', // TODO page2
        method: 'post',
        data
    });
}

/**
 * 分页查询教研室信息
 */
export function findResearchRoom(data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/findResearchRoom',
        method: 'post',
        data
    });
}

export function addItem(data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/page',
        method: 'post',
        data
    });
}

export function getOneById(id, campus, isRetraining) {
    let url = '/api/arrangementservice/MinorClassManagement/getTaskById?id=' + id + '&campus=' + campus;
    if (isRetraining != undefined) {
        url = url + '&isRetraining=' + isRetraining;
    }
    return fetch({
        url: url,
        method: 'get'
    });
    // return fetch({
    //     url: '/api/arrangementservice/MinorClassManagement/getTaskById?id=' + id+'&campus='+campus+'&isRetraining='+isRetrainning,
    //     method: 'get'
    // });
}

export function deleteItem(data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/page',
        method: 'post',
        data
    });
}

/**
 * 任务中添加新的专业
 * @param {任务ID} id
 * @param {新专业} data
 */
export function addProfItem(id, data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/' + id + '/profession/add',
        method: 'post',
        data
    });
}

/**
 * 任务中添加新的教学班
 * @param {任务ID} id
 * @param {新专业} data
 */
export function addClassItem(id, data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/' + id + '/class/add',
        method: 'post',
        data
    });
}

/**
 * 任务中更新某教学班
 * @param {任务ID} id
 * @param {新专业} data
 */
export function updateClassItem(id, data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/' + id + '/class/update',
        method: 'post',
        data
    });
}

/**
 * 任务中删除某教学班前获取教学班排课状态
 * @param {任务ID} id
 * @param {教学班信息} data
 */
export function getClassStatus(data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/class/status',
        method: 'post',
        data
    });
}

/**
 * 任务中删除某教学班
 * @param {任务ID} id
 * @param {教学班信息} data
 */
export function deleteClassItem(id, data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/' + id + '/class/delete',
        method: 'post',
        data
    });
}

/**
 * 任务中删除专业
 * @param {任务ID} taskId
 * @param {需要删除的专业} data
 */
export function deleteProfItem(taskId, data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/' +
      taskId +
      '/profession/delete',
        method: 'post',
        data
    });
}

/**
 * 任务修改专业
 * @param {任务ID} taskId
 * @param {需要修改的专业} data
 */
export function editProfItem(taskId, data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/' +
      taskId +
      '/profession/update',
        method: 'post',
        data
    });
}

/**
 * 合并班级
 * @param {任务ID} taskId
 * @param {需要合班的数组} ids
 */
export function mergeClass(taskId, ids) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/' + taskId + '/class/merge',
        method: 'post',
        data: ids
    });
}

/**
 * 分班级
 * @param {任务ID} taskId
 * @param {分班信息} data
 */
export function splitClase(taskId, data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/' + taskId + '/class/split',
        method: 'post',
        data
    });
}

/**
 * 获取开课信息
 * @param {开课ID} id
 */
export function getOpenClassById(id) {
    return fetch({
        url: '/api/arrangementservice/publicelective/' + id,
        method: 'get'
    });
}

/**
 * 根据学年，学院，专业查询所在的校区
 * @param {查询参数} data
 */
export function findCampus(data) {
    return fetch({
        url: '/api/arrangementservice/professioncampusnum/findCampus',
        method: 'post',
        data
    });
}

/**
 * 根据学年，学院，专业查询所在的校区
 * @param {查询参数} data
 */
export function findGradeProf(data) {
    return fetch({
        url: '/api/arrangementservice/professioncampusnum/findProfessionCampusNumByParam',
        method: 'post',
        data
    });
}
/**
 * 根据学年，学院，专业查询所在的校区下拉列表数据
 * @param {查询参数} data
 */
export function findGradeProfSelsecList(data) {
    return fetch({
        url: '/api/arrangementservice/professioncampusnum/findSelectList',
        method: 'post',
        data
    });
}

export function getCoursesList() {
    return fetch({
        url: '/api/cultureservice/coursesLabel/coursesLabelList',
        method: 'get'
    });
}

export function getCoursesLabelList(data) {
    return fetch({
        url: '/api/cultureservice/coursesLabel/getCoursesLabelList',
        method: 'post',
        data: data
    });
}

/**
 * 导出列表
 * @param {*} data
 */
export function exportList(data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/export',
        method: 'post',
        data: data
    });
}

/**
 * 获取到新的教学班编号
 * @param taskId
 */
export function getNewClassCode(taskId) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/' + taskId + '/class/newcode',
        method: 'get'
    });
}

/**
 * 批量更新任务基础信息
 * @param data
 */
export function updateTaskBatch(data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/updateBatch',
        method: 'post',
        data: data
    });
}

/**
 * 导出
 * @param {*} params
 */
export function getResultByKey(key) {
    return fetch({
        url: '/api/arrangementservice/NonPublicCourseOpen/result/' + key,
        method: 'get'
    });
}
/**
 * 删除
 * @param {*} params
 */
export function deleteTask(key) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/deleteTask',
        method: 'post',
        data: key
    });
}
/**
 * 删除所选
 * @param {*} params
 */
export function deleteTaskSel(key) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/deleteTaskSel',
        method: 'post',
        data: key
    });
}
/**
 * 批量导出
 * @param {} data
 */
export function exportMoreList(data) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/exportMoreList',
        method: 'post',
        data: data
    });
}

/**
 * 查询Redis中指定可以的对象信息
 * @param {}} key
 */
export function getResultByKeyWithOutPre(key) {
    return fetch({
        url: '/api/arrangementservice/teachingClass/resultWithOutPre/' + key,
        method: 'get',
    });
}

/**
 * 删除
 * @param {*} params
 */
export function checkTask(key) {
    return fetch({
        url: '/api/arrangementservice/MinorClassManagement/checkTask',
        method: 'post',
        data: key
    });
}
